# 在当前目录新建目录img, 里面包含10个文件, 10个文件名各不相同(X4G5.png) 将当前img目录所有以.png结尾的后缀名改为.jpg.
import os

path = 'C:\\Users\\wbw\\Desktop\\Whhpython\\homework3\\4img'

# generate 10 files
for i in range( 0, 5 ):
    os.system( 'echo test path' + str(i) + '.png' )

for i in range( 5, 10 ):
    os.system( 'echo test path' + str(i) + '.txt' )

photo_list = os.listdir( path )

for photo in photo_list:
    if '.png' in photo:
        os.rename( path + photo, path + photo.replace( '.png', '.jpg' ) )